<?php
/**
 * Default Login Template
 *
 * @package OWL
 * @subpackage Default Template
 * @author KeiMOon
 * @since 1.0
 */
class Template_Login extends Owl_Master_Template {
    var $layout = "layout-login.php";
    protected function init() {
        $user = Owl_User::get_instance();
        if ($user->is_logged_in()) {
            Owl_Functions::go_to_template("home");
        }
        assign("title", get_option("site_name") . " - " . __("Login"));
        enqueue_style('default-login,default-ajax');
        enqueue_script('default-login');
    }

    protected function main_content() {
?>
<div id="global-header">
    <h2>
        <a href="<?php Owl_Link::site_url() ?>"><?php echo __("Go to your home page") ?></a>
    </h2>
</div>
<div id="main-wrapper">
    <h1><?php echo __("Log in with OWL"); ?></h1>
    <div id="main-form">
        <div class="header">
            <h2><?php echo __("Enter your password") ?></h2>
        </div>
        <div class="content">
            <form action="<?php Owl_Link::ajax_url(); ?>user-ajax.php" method="POST" id="user-login">
                <?php
                Owl_Form::print_hidden(array(
                    "name" => "action",
                    "value" => "user_login"
                ));
                ?>
                <div class="short-column">
                    <?php
                    Owl_Form::print_label(array(
                        "value" => __("Password"),
                        "for" => "user_password"
                    ));
                    ?>
                </div>
                <div class="long-column">
                    <?php
                    Owl_Form::print_textbox(array(
                        'type' => 'password',
                        'name' => 'password',
                        'id' => 'user_password'
                    ));
                    ?>
                </div>
                <div style="clear:both;"></div>
                <div class="short-column">
                    <?php
                    Owl_Form::print_label(array(
                        "value" => __("Language"),
                        "for" => "user_language"
                    ));
                    ?>
                </div>
                <div class="long-column">
                    <?php
                    $langs = array('default' => __('Default language'));
                    $langs = array_merge($langs, Owl_Functions::get_available_languages());
                    Owl_Form::print_combo_box(array(
                        "name" => "lang",
                        "id" => "user_language",
                        "options" => $langs
                    ));
                    ?>
                </div>
                <div style="clear:both;"></div>
                <div class="long-column">
                    <?php
                    Owl_Form::print_label(array(
                        "value" => __("Remember password"),
                        "for" => "user_cookie"
                    ));
                    Owl_Form::print_check_box(array(
                        "name" => "cookie",
                        "id" => "user_cookie"
                    ));
                    ?>
                </div>
                <div class="button-container">
                    <img src="<?php Owl_Link::image_url() ?>default/ajax-load.gif" alt="Ajax load" class="ajax-load" />
                    <a href="#" class="form-button submit"><?php echo __("Login"); ?></a>
                </div>
                <div style="clear:both;"></div>
            </form>
            <?php Owl_Default_Content::print_ajax_feedback(false); ?>
        </div>
    </div>
</div>
<?php
    }
}